#pragma once

#include<iostream>
#include<unistd.h>
#include<fcntl.h>
#include<cstdio>
#include"Log.hpp"
using namespace ns_log;
enum
{
    SOCKED_ERROR = 1,
    BIND_ERROR,
    LISTEN_ERROR,
    ARROW_COMMAND_ERROE,
    EPOLL_CREATE_ERROR
};

//设置文件fd为非阻塞
void SetNoBlock(int fd)
{
    int flag = ::fcntl(fd, F_GETFL);
    if (flag < 0)
    {
        perror("fcntl");
        return;
    }
    if(::fcntl(fd,F_SETFL,flag | O_NONBLOCK) < 0)
    {
        LOG(ERROR,"设置fd = %d非阻塞失败!\n",fd);
    }
}
